﻿using BasicInformation.Domain;
using BasicInformation.Infrastructure.Interface;
using BasicInformation.ReadAPI.Application.Command.OwnerCommand;
using MediatR;

namespace BasicInformation.ReadAPI.Application.CommandHandler.OwnerCommandHandler
{
    public class OwnerInfoCommandHandler : IRequestHandler<OwnerInfoCommand, Owner>
    {
        private readonly IOwnerRepository ownerRepository;

        public OwnerInfoCommandHandler(IOwnerRepository ownerRepository)
        {
            this.ownerRepository = ownerRepository;
        }

        public async Task<Owner> Handle(OwnerInfoCommand request, CancellationToken cancellationToken)
        {
            var info = await ownerRepository.Get(request.Id);
            return info;
        }
    }
}
